/**
 * 
 */
package org.acsis.covoiturage.frontend.actions;

import java.util.Locale;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.RedirectingActionForward;
import org.apache.struts.actions.DispatchAction;
/**
 * @author Abdellah
 *
 */
public class LangueAction extends DispatchAction  {

	public ActionForward fr(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		  String referer = request.getHeader("referer");
	      ActionForward forward = null;
	   
	      this.setLocale(request, Locale.FRANCE);

	      if( referer==null )
	      {
	         forward = (mapping.findForward("success"));
	      }
	      else 
	      {
	         forward = new RedirectingActionForward();
	         forward.setPath( referer );
	      }
		  return forward;
		        
		        
	}

	public ActionForward en(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		
		  String referer = request.getHeader("referer");
	      ActionForward forward = null;
	   
	      this.setLocale(request, Locale.ENGLISH);

	      if( referer==null )
	      {
	         forward = (mapping.findForward("success"));
	      }
	      else 
	      {
	         forward = new RedirectingActionForward();
	         forward.setPath( referer );
	      }
		  return forward;
	}
}
